﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:UTable.Objects.Controls">
    
    <Style TargetType="local:UDrawer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:UDrawer}">
                    <Border>
                        <Grid x:Name="PART_Container">
                            <Grid.RowDefinitions>
                                <RowDefinition MaxHeight="{TemplateBinding HandleLength}" MinHeight="{TemplateBinding HandleLength}"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid Grid.Row="0" x:Name="HandleContainer">
                                <local:UDrawerHandle x:Name="PART_Handle">
                                    <local:UDrawerHandle.Style>
                                        <Style TargetType="{x:Type local:UDrawerHandle}">
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="{x:Type local:UDrawerHandle}">
                                                        <Grid>
                                                            <Grid.Background>
                                                                <ImageBrush ImageSource="../Images/DrawerHandle.png" Stretch="Fill"/>
                                                            </Grid.Background>
                                                        </Grid>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </local:UDrawerHandle.Style>
                                </local:UDrawerHandle>
                                <TextBlock IsHitTestVisible="False" Text="{TemplateBinding DrawerName}" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" Foreground="#622800" FontWeight="Bold"/>
                            </Grid>
                            <Grid Grid.Row="1" x:Name="ContentContainer">
                                <Grid x:Name="ContentBackgroundContainer">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="60"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="60"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid Grid.Column="0">
                                        <Grid.Background>
                                            <ImageBrush ImageSource="../Images/UDrawerGridLeft.png" TileMode="Tile" Viewport="0, 0, 60, 192" ViewportUnits="Absolute"/>
                                        </Grid.Background>
                                    </Grid>
                                    <Grid Grid.Column="1">
                                        <Grid.Background>
                                            <ImageBrush ImageSource="../Images/UDrawerGridMiddle.png" TileMode="Tile" Viewport="0, 0, 15, 192" ViewportUnits="Absolute"/>
                                        </Grid.Background>
                                    </Grid>
                                    <Grid Grid.Column="2">
                                        <Grid.Background>
                                            <ImageBrush ImageSource="../Images/UDrawerGridRight.png" TileMode="Tile" Viewport="0, 0, 60, 192" ViewportUnits="Absolute"/>
                                        </Grid.Background>
                                    </Grid>
                                </Grid>
                                <ContentPresenter/>
                            </Grid>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="OpenDirection" Value="Left">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type local:UDrawer}">
                            <Border>
                                <Grid x:Name="PART_Container">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition MaxWidth="{TemplateBinding HandleLength}" MinWidth="{TemplateBinding HandleLength}"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid Grid.Column="0" x:Name="HandleContainer">
                                        <Grid.LayoutTransform>
                                            <RotateTransform CenterX="0" CenterY="0" Angle="-90"/>
                                        </Grid.LayoutTransform>
                                        <local:UDrawerHandle x:Name="PART_Handle">
                                            <local:UDrawerHandle.Style>
                                                <Style TargetType="{x:Type local:UDrawerHandle}">
                                                    <Setter Property="Template">
                                                        <Setter.Value>
                                                            <ControlTemplate TargetType="{x:Type local:UDrawerHandle}">
                                                                <Grid>
                                                                    <Grid.Background>
                                                                        <ImageBrush ImageSource="../Images/DrawerHandle.png" Stretch="Fill"/>
                                                                    </Grid.Background>
                                                                </Grid>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </local:UDrawerHandle.Style>
                                        </local:UDrawerHandle>
                                        <TextBlock IsHitTestVisible="False" Text="{TemplateBinding DrawerName}" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" Foreground="#622800" FontWeight="Bold"/>
                                    </Grid>
                                    <Grid Grid.Column="1" x:Name="ContentContainer">
                                        <Grid x:Name="ContentBackgroundContainer">
                                            <Grid.LayoutTransform>
                                                <RotateTransform CenterX="0" CenterY="0" Angle="-90"/>
                                            </Grid.LayoutTransform>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="60"/>
                                                <ColumnDefinition Width="*"/>
                                                <ColumnDefinition Width="60"/>
                                            </Grid.ColumnDefinitions>
                                            <Grid Grid.Column="0">
                                                <Grid.Background>
                                                    <ImageBrush ImageSource="../Images/UDrawerGridLeft.png" TileMode="Tile" Viewport="0, 0, 60, 192" ViewportUnits="Absolute"/>
                                                </Grid.Background>
                                            </Grid>
                                            <Grid Grid.Column="1">
                                                <Grid.Background>
                                                    <ImageBrush ImageSource="../Images/UDrawerGridMiddle.png" TileMode="Tile" Viewport="0, 0, 15, 192" ViewportUnits="Absolute"/>
                                                </Grid.Background>
                                            </Grid>
                                            <Grid Grid.Column="2">
                                                <Grid.Background>
                                                    <ImageBrush ImageSource="../Images/UDrawerGridRight.png" TileMode="Tile" Viewport="0, 0, 60, 192" ViewportUnits="Absolute"/>
                                                </Grid.Background>
                                            </Grid>
                                        </Grid>
                                        <ContentPresenter/>
                                    </Grid>
                                </Grid>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="OpenDirection" Value="Down">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type local:UDrawer}">
                            <Border>
                                <Grid x:Name="PART_Container">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition MaxHeight="{TemplateBinding HandleLength}" MinHeight="{TemplateBinding HandleLength}"/>
                                    </Grid.RowDefinitions>
                                    <Grid Grid.Row="1" x:Name="HandleContainer">
                                        <local:UDrawerHandle x:Name="PART_Handle">
                                            <local:UDrawerHandle.Style>
                                                <Style TargetType="{x:Type local:UDrawerHandle}">
                                                    <Setter Property="Template">
                                                        <Setter.Value>
                                                            <ControlTemplate TargetType="{x:Type local:UDrawerHandle}">
                                                                <Grid>
                                                                    <Grid.Background>
                                                                        <ImageBrush ImageSource="../Images/DrawerHandle.png" Stretch="Fill"/>
                                                                    </Grid.Background>
                                                                </Grid>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </local:UDrawerHandle.Style>
                                        </local:UDrawerHandle>
                                        <TextBlock IsHitTestVisible="False" Text="{TemplateBinding DrawerName}" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" Foreground="#622800" FontWeight="Bold"/>
                                    </Grid>
                                    <Grid Grid.Row="0" x:Name="ContentContainer">
                                        <Grid x:Name="ContentBackgroundContainer">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="60"/>
                                                <ColumnDefinition Width="*"/>
                                                <ColumnDefinition Width="60"/>
                                            </Grid.ColumnDefinitions>
                                            <Grid.LayoutTransform>
                                                <RotateTransform CenterX="0" CenterY="0" Angle="180"/>
                                            </Grid.LayoutTransform>
                                            <Grid Grid.Column="0">
                                                <Grid.Background>
                                                    <ImageBrush ImageSource="../Images/UDrawerGridLeft.png" TileMode="Tile" Viewport="0, 0, 60, 192" ViewportUnits="Absolute"/>
                                                </Grid.Background>
                                            </Grid>
                                            <Grid Grid.Column="1">
                                                <Grid.Background>
                                                    <ImageBrush ImageSource="../Images/UDrawerGridMiddle.png" TileMode="Tile" Viewport="0, 0, 15, 192" ViewportUnits="Absolute"/>
                                                </Grid.Background>
                                            </Grid>
                                            <Grid Grid.Column="2">
                                                <Grid.Background>
                                                    <ImageBrush ImageSource="../Images/UDrawerGridRight.png" TileMode="Tile" Viewport="0, 0, 60, 192" ViewportUnits="Absolute"/>
                                                </Grid.Background>
                                            </Grid>
                                        </Grid>
                                        <ContentPresenter/>
                                    </Grid>
                                </Grid>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="OpenDirection" Value="Right">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type local:UDrawer}">
                            <Border>
                                <Grid x:Name="PART_Container">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition MaxWidth="{TemplateBinding HandleLength}" MinWidth="{TemplateBinding HandleLength}"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid Grid.Column="1" x:Name="HandleContainer">
                                        <Grid.LayoutTransform>
                                            <RotateTransform CenterX="0" CenterY="0" Angle="90"/>
                                        </Grid.LayoutTransform>
                                        <local:UDrawerHandle x:Name="PART_Handle">
                                            <local:UDrawerHandle.Style>
                                                <Style TargetType="{x:Type local:UDrawerHandle}">
                                                    <Setter Property="Template">
                                                        <Setter.Value>
                                                            <ControlTemplate TargetType="{x:Type local:UDrawerHandle}">
                                                                <Grid>
                                                                    <Grid.Background>
                                                                        <ImageBrush ImageSource="../Images/DrawerHandle.png" Stretch="Fill"/>
                                                                    </Grid.Background>
                                                                </Grid>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </local:UDrawerHandle.Style>
                                        </local:UDrawerHandle>
                                        <TextBlock IsHitTestVisible="False" Text="{TemplateBinding DrawerName}" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" Foreground="#622800" FontWeight="Bold"/>
                                    </Grid>
                                    <Grid Grid.Column="0" x:Name="ContentContainer">
                                        <Grid x:Name="ContentBackgroundContainer">
                                            <Grid.LayoutTransform>
                                                <RotateTransform CenterX="0" CenterY="0" Angle="90"/>
                                            </Grid.LayoutTransform>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="60"/>
                                                <ColumnDefinition Width="*"/>
                                                <ColumnDefinition Width="60"/>
                                            </Grid.ColumnDefinitions>
                                            <Grid Grid.Column="0">
                                                <Grid.Background>
                                                    <ImageBrush ImageSource="../Images/UDrawerGridLeft.png" TileMode="Tile" Viewport="0, 0, 60, 192" ViewportUnits="Absolute"/>
                                                </Grid.Background>
                                            </Grid>
                                            <Grid Grid.Column="1">
                                                <Grid.Background>
                                                    <ImageBrush ImageSource="../Images/UDrawerGridMiddle.png" TileMode="Tile" Viewport="0, 0, 15, 192" ViewportUnits="Absolute"/>
                                                </Grid.Background>
                                            </Grid>
                                            <Grid Grid.Column="2">
                                                <Grid.Background>
                                                    <ImageBrush ImageSource="../Images/UDrawerGridRight.png" TileMode="Tile" Viewport="0, 0, 60, 192" ViewportUnits="Absolute"/>
                                                </Grid.Background>
                                            </Grid>
                                        </Grid>
                                        <ContentPresenter/>
                                    </Grid>
                                </Grid>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>
